public class Leetcode {
}

//leetcode:LCR069:山脉数组峰顶的索引
class Solution1 {
    public int peakIndexInMountainArray(int[] arr) {
        int left = 1,right = arr.length-2;
        while(left < right){
            int mid = left + (right - left) / 2;
            if(arr[mid] < arr[mid+1]){
                left = mid+1;
            }else{
                right = mid;
            }
        }
        return right;
    }
}

//leetcode:162:寻找峰值
class Solution2 {
    public int findPeakElement(int[] nums) {
        int left = 0,right = nums.length-1;
        while(left < right){
            int mid = left + (right - left) / 2;
            if(nums[mid] < nums[mid+1]){
                left = mid + 1;
            }else{
                right = mid;
            }
        }
        return left;
    }
}

//leetcode:153:寻找旋转排序数组中的最小值
class Solution3 {
    public int findMin(int[] nums) {
        int left = 0,right = nums.length - 1;
        int x = nums[right];
        while(left < right){
            int mid = left + (right - left) / 2;
            if(nums[mid] > x){
                left = mid+1;
            }else{
                right = mid;
            }
        }
        return nums[left];
    }
}

//leetcode:LCR173：点名
class Solution4 {
    public int takeAttendance(int[] records) {
        int left = 0,right = records.length-1;
        while(left < right){
            int mid = left + (right - left) /2;
            if(records[mid] == mid){
                left = mid +1;
            }else{
                right = mid;
            }
        }
        return records[left] == left ? left+1 : left;
    }
}